/*
I am a CPHO compititor!
I love physics
wy & chengjiafu &shuyousheng & yebangjiao bless tyc
*/
#include<bits/stdc++.h>
//~ #define p 998244353
//~ #define int long long
#define pr pair<int,int>
#define mp make_pair
#define fi first
#define se second 
using namespace std;
template<typename T>inline void read(T &x){
	T f=1;char ch=getchar();x=0;
	for(;!isdigit(ch);ch=getchar())if(ch=='-')f=-1;
	for(;isdigit(ch);ch=getchar())x=(x<<3)+(x<<1)+ch-'0';
	x*=f;
}
template<typename T>inline void write(T x){
	if(x<0){putchar('-');x=-x;}
	if(x<10){putchar(x+'0');return;}
	write(x/10);
	putchar(x%10+'0');
}
int v0[100010],a[100010],x0[100010];
bool road[1000010];
int pre[1000010];
int n,m,L,vm;
vector<pr>q,b;
void solve(){
	read(n);read(m);read(L);read(vm);
	q.clear();
	b.clear();
	memset(road,0,sizeof(road));
	for(int i=1;i<=n;i++){
		read(x0[i]);read(v0[i]);read(a[i]);
	}
	for(int i=1;i<=m;i++){
		int x;
		read(x);
		road[x]=1;
	}
	pre[0]=road[0];//0!!!
	for(int i=1;i<=L;i++){
		pre[i]=pre[i-1]+road[i];
	}
	for(int i=1;i<=n;i++){
		//fen lei tao lun
		int l,r;
		if(v0[i]>vm){
			if(a[i]>=0)l=x0[i],r=L;
			if(a[i]<0)l=x0[i],r=min(L,x0[i]+(v0[i]*v0[i]-vm*vm-1)/(-2*a[i]));
		}
		if(v0[i]<=vm){
			if(a[i]<=0)continue;
			if(a[i]>0){
				l=x0[i]+(vm*vm-v0[i]*v0[i])/(2*a[i])+1;//?
				if(l>L)continue;
				r=L;
			}
		}
		if(pre[r]==(l?pre[l-1]:0))continue;
		//~ if(v0[i]<=vm)cout<<"!!!!\n";
		q.push_back(mp(l,r));
	}
	write(q.size());putchar(' ');
	//now it's OI progress.
	
	sort(q.begin(),q.end());
	for(int i=0;i<q.size();i++){
		while(!b.empty()&&q[i].se<=b.back().se)b.pop_back();
		b.push_back(q[i]);
	}
	pre[0]=road[0]?-1:0;//0!!!
	for(int i=1;i<=L;i++){
		pre[i]=(road[i]?i:pre[i-1]);
	}
	
	//~ cout<<"q:\n";
	//~ for(int i=0;i<q.size();i++){
		//~ cout<<q[i].fi<<" "<<q[i].se<<endl;
	//~ }
	//~ cout<<"b:\n";
	//~ for(int i=0;i<b.size();i++){
		//~ cout<<b[i].fi<<" "<<b[i].se<<endl;
	//~ }
	int k=0,s=0;
	while(k<b.size()){
		s++;
		int pnt=pre[b[k].se];
		//~ cout<<k<<" "<<s<<" "<<pnt<<endl;
		while(k<b.size()&&b[k].fi<=pnt)k++;
	}
	write(m-s);putchar('\n');
}
signed main(){
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int T;
	read(T);
	while(T--)
		solve();
	return 0;
}
//20090626
/*


1
5 5 15 3
0 3 0
12 4 0
1 1 4
5 5 -2
6 4 -4
2 5 8 9 15

1
10 10 175391 226
31181 234 -546
32757 670 -9
43723 775 -3
78541 862 -4
26626 961 -13
54690 759 -998
56165 659 -3
56531 776 -34
32860 950 -6
86709 145 47
31182 33025 46753 52673 57685 60635 99569 124240 162898 170704


*/
